within ThreeD_MBS_Dynamics.Examples.Snakeboard;

model Test_HalfWheelSet
  parameter SI.Acceleration g=9.81;
  parameter SI.Acceleration[3] Gravity={0,-g,0};
  parameter SI.Mass m_rod=0.5;
  parameter SI.Mass m_disc=1;
  parameter SI.Radius r1=2;
  parameter SI.Radius r2=0.1;
  parameter SI.Length L=2;
  parameter SI.AngularVelocity omega0=1;
  parameter Real alpha=Modelica.Constants.pi;
  Disc Disc1(
    Gravity=Gravity,
    r1=r1,
    q(start={1,0,0,0}),
    I=m_disc*[0.25*r1^2, 0, 0; 0, 0.25*r1^2, 0; 0, 0, 0.5*r1^2],
    v(start={-r1*omega0,0,0}),
    omega(start={0,0,omega0}),
    r(start={0,r1,L/2})) annotation (extent=[-44,10; -4,50]);
  Disc_on_Base Disc_on_Plane1 annotation (extent=[-92,10; -52,50]);
  Base Base1 annotation (extent=[-20,-50; 20,-10]);
  annotation (
    Diagram,
    experiment(
      StopTime=10,
      NumberOfIntervals=5000,
      Tolerance=1e-009),
    experimentSetupOutput);
  RodUni Rod1(
    Gravity=Gravity,
    r2=r2,
    m=m_rod,
    L=L,
    q(start={1,0,0,0}),
    I=0.25*m_rod*[L^2/3 + r2^2, 0, 0; 0, L^2/3 + r2^2, 0; 0, 0, 2*r2^2],
    v(start={-r1*omega0,0,0}),
    omega(start={0,0,0}),
    r(start={0,r1,0})) annotation (extent=[52,10; 92,50]);
  FixedJoint Joint1(
    nA={0,0,1},
    nB={0,0,1},
    rA={0,0,0},
    rB={0,0,0.5*L}) annotation (extent=[4,10; 44,50]);
//  FreeJoint Joint1(
//    bA={1,0,0},
equation
  connect(Disc_on_Plane1.InPortB, Disc1.OutPort) 
    annotation (points=[-66,12; -66,0; -24,0; -24,12]);
  connect(Joint1.InPortB, Rod1.OutPort) 
    annotation (points=[30,12; 30,0; 72,0; 72,12]);
  connect(Disc1.InPortJoint, Joint1.OutPortA) 
    annotation (points=[-18,48; -18,60; 18,60; 18,48]);
  connect(Joint1.InPortA, Disc1.OutPort) 
    annotation (points=[18,12; 18,0; -24,0; -24,12]);
  connect(Disc1.InPortRoll, Disc_on_Plane1.OutPortB) annotation (points=[
        -30,48; -30,60; -66,60; -66,48], style(color=3, rgbcolor={0,0,255}));
  connect(Joint1.OutPortB, Rod1.InPortJointA) annotation (points=[30,48;
        30,60; 72,60; 72,48], style(color=3, rgbcolor={0,0,255}));
  connect(Disc_on_Plane1.InPortA, Base1.OutPort) annotation (points=[-78,
        12; -78,-60; 0,-60; 0,-48], style(color=3, rgbcolor={0,0,255}));
end Test_HalfWheelSet;
